Regular expressions, or more generally patterns, describe sets of character strings. The pattern determines character strings that belong to the set. Accordingly, patterns can be employed to identify character strings, for example, to select specific strings from a set of character strings. Furthermore, regular expressions are often defined as a context-independent syntax that can represent a wide variety of character sets and character set orderings.
In operation, regular expressions can be employed to search and match data as a function of a predefined pattern or set of patterns. As such, patterns employ a specific syntax by which particular characters or strings are selected from a body of text. More specifically, the expressions can consist of constants and operators that denote sets of strings and operations over these sets, respectively. Using the specific syntax of a regular expression or other pattern language, advanced text pattern matching can be performed. Table 1 that follows lists exemplary regular expression operators and their definitions. The syntax illustrated in the table is frequently employed to establish both simple and complex string pattern identifications.
TABLE 1CharacterDefinition.Matches any single character.[ ]Matches any single character from within the bracketed list. Withinsquare brackets, most characters are interpreted literally.[{circumflex over ( )}]Specifies a set of characters not to be matched.{circumflex over ( )}Matches the beginning of a line.$Matches the end of a line.|Matches either the regular expression preceding it or the regularexpression following it.( )Groups one or more regular expressions to establish a logical regularexpression consisting of sub-regular expressions. Used to override thestandard precedence of certain operators.?Specifies that the preceding regular expression is matched 0 or 1 time.*Specifies that the preceding regular expression is matched 0 or more times.+Specifies that the preceding regular expression is matched 1 or moretimes.{n}Specifies that the preceding regular expression is matched exactly “n”number of times.{n,}Specifies that the preceding regular expression is matched “n” or more times.{, n}Specifies that the preceding regular expression is matched “n” or fewertimes.{n, m}Specifies that the preceding regular expression is matched a maximum of“n” times and a minimum of “m” times. If not specified, “m” defaults to“0.”If “n” is not specified, the default depends on whether the comma ispresent. If no comma is present, “n” defaults to “m.” If a comma ispresent, “n” defaults to a very large number.\nMatches a new line.\tMatches a tab character.
Regular expressions are a useful tool many areas. For example, regular expressions are utilized by compilers to identify tokens and otherwise translate computer-programming code. Similarly, code completion and/or highlighting systems utilize regular expressions in integrated development environments. Regular expressions are also useful in the data flow field, which pertains to the movement and transformation of data to and amongst storage mediums.